<template>
  <div class="applylist-container">
    <van-list v-if="showList"
      v-model="listView.loading"
      :finished="listView.finished"
      finished-text="没有更多了"
      @load="loadApplyList">
      <applyItem :detail="apply" v-for="(apply, index) in listView.list" :key="index"></applyItem>
    </van-list>
    <van-empty v-if="!showList"
      image="imgs/empty.png"
      description="暂无申请记录~"
    />
  </div>
</template>

<script>
import { mapState } from 'vuex'
import constants from '@/config/constants'
import orderApi from '@/api/orderApi'
import utils from '@/utils/utils'
import applyItem from '../components/applyItem.vue'

export default {
  components: {
    applyItem
  },
  name: 'applyList',
  props: ['status'],
  computed: {
    ...mapState(['user'])
  },
  data () {
    return {
      showList: true,
      /* 申请列表 */
      listView: {
        params: {
          memberId: '',
          returnStatus: '',
          pageNo: 1,
          pageSize: 10
        },
        loading: false,
        finished: false,
        list: []
      }
    }
  },
  methods: {
    /* 获取申请列表 */
    loadApplyList() {
      this.listView.params.memberId = this.user.id;
      this.listView.params.returnStatus = this.status;
      orderApi.orderReturnApplyList(this.listView.params).then(result => {
				if(result.code == constants.SUCCESS){
					utils.pageResultHandle(this.listView, result.data);
					if(result.totalCount == 0){
					  this.showList = false;
					}
				}
      })
    }
  }
}
</script>

<style lang="scss">
.applylist-container{
  margin-bottom: 20px;
  margin-top: 10px;
}
</style>
